home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v7n19.arc / PAGEDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1988-10-14  |  4KB  |  114 lines

  1. {$R+,C-}
  2. PROGRAM PageDemo;
  3. TYPE
  4.   String80 = STRING[80];
  5.   Regpack = RECORD
  6.     CASE Integer OF
  7.       1:(AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer);
  8.       2:(AL,AH,BL,BH,CL,CH,DL,DH : Byte);
  9.     END;
  10. VAR
  11.   Regs  : RegPack;
  12.   Data  : String80;
  13.   I, J  : Integer;
  14.   dummy : Char;
  15.  
  16.  
  17.   PROCEDURE Setpage(page : Byte);
  18.     { Sets the current displayed page using INT 10h.  All "Writes" }
  19.     { still goes to page 0 -- this procedure just changes which    }
  20.     { page is visible.                                             }
  21.   BEGIN
  22.     Regs.AH := 5;
  23.     Regs.AL := page;
  24.     Intr($10, Regs);
  25.   END;
  26.  
  27.   PROCEDURE ClrPage(Page, Background : Byte);
  28.     { Clears the page using INT 10h services to write spaces }
  29.     { over the whole page.                                   }
  30.   BEGIN
  31.     WITH Regs DO
  32.       BEGIN
  33.         {** Locate cursor first **}
  34.         DL := 0;              { Column              }
  35.         DH := 0;              { Row                 }
  36.         BH := Page;           { Page                }
  37.         AH := 2;              { Set Cursor Position }
  38.         Intr($10, Regs);
  39.         {** Now write characters **}
  40.         AH := 9;              { Write Char w/ attr. }
  41.         BH := Page;           { Page                }
  42.         BL := Background*16;  { attribute byte      }
  43.         AL := Ord(' ');       { Char to write       }
  44.         CX := 2000;           { # of times to write }
  45.         Intr($10, Regs);
  46.       END;
  47.   END;
  48.  
  49.  
  50.   PROCEDURE PutPage(VAR Data : String80; Page, Col, Row, Back, Fore : Byte);
  51.     { Uses INT 10h to write a string to the selected page. }
  52.     { Arguments are:                                       }
  53.     {    1) A String[80] to write    }
  54.     {    2) the Page to Write to     }
  55.     {    3) the Column To Start at   }
  56.     {    4) the Row To Write in      }
  57.     {    5) the BackGround Color     }
  58.     {    6) the Foreground Color     }
  59.   VAR
  60.     Endcol : Byte;
  61.     L, I   : Integer;
  62.   BEGIN
  63.     Col := Col-1; {Turbo uses 1..80, BIOS uses 0..79}
  64.     Row := Row-1; {Turbo uses 1..25, BIOS uses 0..24}
  65.     IF (Col < 0) OR (Col > 79) THEN Col := 0;
  66.     IF (Row < 0) OR (Row > 24) THEN Row := 0;
  67.     IF (Page < 0) OR (Page > 3) THEN Page := 0;
  68.     L := Length(Data);
  69.     EndCol := Col+L;
  70.     IF EndCol > 79 THEN
  71.       BEGIN
  72.         EndCol := 79;
  73.         L := EndCol-Col;
  74.       END;
  75.     FOR I := 0 TO (L-1) DO
  76.       BEGIN
  77.         WITH Regs DO
  78.           BEGIN
  79.             {  **  Locate Cursor First  ** }
  80.             DL := Col+I;      { Column              }
  81.             DH := Row;        { Row                 }
  82.             BH := Page;       { Page                }
  83.             AH := 2;          { Set Cursor Position }
  84.             Intr($10, Regs);
  85.             { Now Write Character }
  86.             AH := 9;          { Write Char w/ attr. }
  87.             BH := Page;       { Page                }
  88.             BL := Back*16+Fore; { attribute byte    }
  89.             AL := Ord(Data[I+1]); {char to write    }
  90.             CX := 1;          { # of times to write }
  91.             Intr($10, Regs);
  92.           END;
  93.       END;
  94.   END;
  95.  
  96. BEGIN
  97.   WriteLn('WARNING: ONLY works on color/graphics system.');
  98.   FOR J := 1 TO 3 DO
  99.     BEGIN
  100.       Data := 'Data Data Data Data Data Data Data Data '+
  101.               'Data Data Data Data Data Data Data Data ';
  102.       WriteLn('Building Page ', J);
  103.       ClrPage(J, J);
  104.       FOR I := 1 TO 24 DO
  105.         Putpage(Data, J, 1, I, J, White);
  106.       Data := 'Press any key to continue...';
  107.       PutPage(Data, J, 1, 25, White, J);
  108.     END;
  109.   WriteLn('Press key for first page'); Read(Kbd, dummy);
  110.   setpage(1); Read(Kbd, dummy);
  111.   setpage(2); Read(Kbd, dummy);
  112.   setpage(3); Read(Kbd, dummy);
  113.   setpage(0); WriteLn('We''re back'); {Read(Kbd, dummy);}
  114. END.